package com.yocard.yxyd.ui.presenter;

import com.yocard.yxyd.base.CommonSubscriber;
import com.yocard.yxyd.base.RxPresenter;
import com.yocard.yxyd.http.HttpManager;
import com.yocard.yxyd.http.model.response.InviteResponse;
import com.yocard.yxyd.ui.contract.InviteFriendsContract;
import com.yocard.yxyd.utils.RxUtil;

import javax.inject.Inject;

/**
 * Created on 2019/4/9.
 */
public class InviteFriendsPresenter extends RxPresenter<InviteFriendsContract.View> implements InviteFriendsContract.Presenter {

    @Inject
    public InviteFriendsPresenter(HttpManager manager) {
        super(manager);
    }

    @Override
    public void getInviteInfo() {
        addSubscribe(httpManager.getInviteInfo().compose(RxUtil.rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<InviteResponse>(mView) {
                    @Override
                    public void onSuccess(InviteResponse bannerBean) {
                        try {
                            mView.OnFetchInviteInfo(bannerBean);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }));

    }
}
